﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace readwrite
{
    class Program
    {
        static void Main(string[] args)
        {

            WriteToFile();
            ReadFromFile("c:\\MyTextFile.txt");
        }
            static void WriteToFile()
            {
                StreamWriter SW;
                SW = File.CreateText("c:\\MyTextFile.txt");
                SW.WriteLine("God is greatest of them all");
                SW.WriteLine("This is second line");
                SW.Close();
                Console.WriteLine("File Created SucacessFully");
            }
            static void ReadFromFile(string filename)
            {
                StreamReader SR;
                string S;
                SR = File.OpenText(filename);
                S = SR.ReadLine();
                while (S != null)
                {
                    Console.WriteLine(S);
                    S = SR.ReadLine();
                }
                SR.Close();
            }
        
       
        }

    }
